//package com.zhuss.product.processor;
//
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.OutputStream;
//import java.util.LinkedHashMap;
//import java.util.List;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//import com.zhuss.bean.unit.product.TrainItem;
//import com.zhuss.bean.vo.core.DetailImportVo;
//import com.zhuss.bean.vo.product.train.ListTrainVo;
//import com.zhuss.exception.DzcxException;
//import com.zhuss.exception.ExceptionCode;
//import com.zhuss.util.ExcelUtil;
//import com.zhuss.util.NoUtil;
//
//@Component
//public class TrainExport {
//
//	@Value("${filePath}")
//    private String filePath;
//
//	@Value("${fileReadPath}")
//	private String fileReadPath;
//
//	public Object process(List<ListTrainVo> trainList) throws DzcxException {
//		transfer(trainList);
//		if (trainList.isEmpty()) {
//			trainList.add(new ListTrainVo());
//		}
//		String url = "";
//		String path = filePath + "batch\train\\";
//		String readPath = fileReadPath +  "batch\train\\";
//		String fileName = "";
//		fileName = NoUtil.gen();
//		File file2 = new File(path);
//		if (!file2.exists()) {
//			file2.mkdirs();
//		}
//		LinkedHashMap<String,String> map = ExcelUtil.getExportTrainMap();
//		File file3 = new File(path + "车次导出-" + fileName + ".xls");
//		OutputStream os = null;
//		try {
//			os = new FileOutputStream(file3);
//			ExcelUtil.listToExcel(trainList, map, "车次导出", os);
//		} catch (Exception e) {
//			e.printStackTrace();
//			throw new DzcxException(ExceptionCode.导出失败);
//		}
//
//		url = readPath + file3.getName();
//
//		DetailImportVo result = new DetailImportVo();
//		result.setUrl(url);
//		return result;
//	}
//
//	private void transfer(List<ListTrainVo> trainList) {
//		for (ListTrainVo vo : trainList) {
//			StringBuffer sb = new StringBuffer();
//			sb.append("[");
//			for (TrainItem pi : vo.getTrainList()) {
//				String name = pi.getTrainName() + " X " + pi.getCount();
//				sb.append(name);
//				sb.append(",");
//			}
//			int i = sb.lastIndexOf(",");
//			if (i != -1) {
//				sb.deleteCharAt(i);
//			}
//			sb.append("]");
//			vo.setTrainListName(sb.toString());
//			vo.setTypeName(vo.getTypeName());
//			vo.setAmountName(vo.getAmountName());
//			vo.setStatusName(vo.getStatusName());
//			vo.setCreateTimeName(vo.getCreateTimeName());
//		}
//
//	}
//
//}
